<template>
	<view class="">
		<view class="display-sb1 header1" @tap="goBack">
			<view class="flex align-center" style="margin-left: 20rpx;">
				<u-icon name="arrow-left" size="40"></u-icon>
			</view>
			<view class="" style="34rpx">
				积分转出
			</view>
			<view class="">
			</view>
		</view>
		
		
		
		<view class="money">
			<text style="font-size: 28rpx;margin-bottom: 20rpx;">可用积分 </text>
			<view class="">
				<u-count-to :start-val="0" color="#FFF" :end-val="info || '0'"></u-count-to>
			</view>
		</view>
		
		
		
		<view class="center1">
			<view class="flex align-center center-box">
				<view class="">
					接收人
				</view>
				<view class="" style="margin-left: 10rpx;">
					<input type="text"
					v-model="phone"
					placeholder="请输入接收人手机号"
					placeholder-style="font-size: 24rpx"/>
				</view>
			</view>
			<view class="" 
				style="border-top: 1rpx solid #EEEEEE; 
				width: 100%;height: 1rpx;">
			</view>
			<view class="flex align-center center-box">
				<view class="">
					积分转出
				</view>
				<view class="" style="margin-left: 10rpx;">
					<input type="text" v-model="numInput"
					placeholder-style="font-size: 24rpx"
					placeholder="请输入要转入的积分" />
				</view>
			</view>
		</view>
		
		
		<view class="add-text" @tap="add">
			确认转账
		</view>
	</view>
</template>

<script>
	import { mapMutations, mapActions, mapState } from 'vuex';
	
	export default{
		data() {
			return {
				numInput: '',
				phone: '',
				info: '',
			}
		},
		onLoad() {
			this.getInfo()
		},
		methods:{
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			
			getInfo () {
				this.$api('user.info',{
				}).then(res => {
					if(res.code == 1) {
						this.info = res.data.money
					} 
				}) 
			},
			
			// 转账
			add () {
				this.$api('user.huzhuan',{
					num: this.numInput,
					mobile: this.phone
				}).then(res => {
					if(res.code == 1) {
						this.$tools.toast(res.msg)
						this.numInput = ''
						this.phone = ''
						this.getInfo()
					} 
				}) 
			},
		}
	}
</script>

<style lang="less" scoped>
	.header1 {
		width: 100%;
		height: 120rpx;
		line-height: 120rpx;
		color: #FFFFFF;
		background-color:#477afa ;
	}
	
	.money {
		width: 100%;
		height: 200rpx;
		color: #FFFFFF;
		padding-left: 30rpx;
		font-size: 40rpx;
		background-color:#477afa;
	}
	
	.center1 {
		width: 90%;
		margin: 20rpx auto;
		border-radius: 10rpx;
		background-color: #FFFFFF;
		
		.center-box {
			width: 80%;
			margin: 0 auto;
			height: 80rpx;
			line-height: 80rpx;
		}
	}
	
	.add-text {
		width: 80%;
		height: 80rpx;
		color: #FFFFFF;
		margin: 0 auto;
		border-radius: 10rpx;
		line-height: 80rpx;
		text-align: center;
		background-color: #477afa;
	}
</style>
